package com.kuang.org.controller;

import com.kuang.bascic.Myexception.BusinessException;
import com.kuang.bascic.utils.Ajax;
import com.kuang.bascic.utils.AjaxResult;
import com.kuang.bascic.utils.ExcelUtil;
import com.kuang.bascic.utils.PageList;
import com.kuang.org.domain.Department;
import com.kuang.org.domain.Shop;
import com.kuang.org.domain.Shopauditlog;
import com.kuang.org.query.DepartmentQuery;
import com.kuang.org.query.ShopQuery;
import com.kuang.org.service.ShopService;
import com.kuang.org.service.ShopauditlogService;
import io.swagger.annotations.ApiOperation;
import org.csource.common.MyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sun.awt.geom.AreaOp;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/shop")
public class ShopController {
    @Autowired
    private ShopService shopService;
    @Autowired
    private ShopauditlogService shopauditlogService;


    @PostMapping("/settlement")
    public AjaxResult updataShop(@RequestBody Shop shop){
        System.out.println(shop);
        try {
            shopService.settlement(shop);
        } catch (BusinessException e) {
            return AjaxResult.me().setMessage(e.getMessage());
        }
        return  new AjaxResult();
    }
    @PostMapping
    @ApiOperation(value = "分页查询" )
    public PageList<Shop> selectPage(@RequestBody ShopQuery shopQuery){
        //RequestBody 接受前端穿的json数据格式 ，@ResponseBody表示返回给前端json数据格式
        PageList<Shop> pageList = shopService.pageList(shopQuery);
        System.out.println(pageList);
        return pageList;
    }
    @PostMapping("/audit/pass")
    @ApiOperation(value = "分页查询" )
    public AjaxResult pass(@RequestBody Shopauditlog shopauditlog){
        shopauditlogService.pass(shopauditlog);
        return null;
    }
    @GetMapping("/export")
    public void export(HttpServletResponse response){
        List<Shop> shops = shopService.selectAllDepartment();
//        ExcelUtil.exportExcel(shops,"店铺名称","11",);
    }


    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


}

